import request from '@/utils/request';
import { setToken } from '@/utils/token-util';

/**
 * 登录
 */
export async function login(data) {
  // data.tenantId = 1; // 租户id
  const res = await request.post('/auth/login', data);
  if (res.data.code === 2000) {
    setToken(res.data.data, true);
    return '登陆成功';
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 获取验证码
 */
export async function getCaptcha() {
  const res = await request.get('/auth/captcha/getCaptcha');
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
